﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SteelDetection
{
    /// <summary>
    /// WindowDefectInfoDlg.xaml 的交互逻辑
    /// </summary>
    public partial class WindowDefectInfoDlg : Window
    {
        public WindowDefectInfoDlg()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.Manual;
            var mouseX = System.Windows.Forms.Control.MousePosition.X;
            this.Left = SystemParameters.FullPrimaryScreenWidth - mouseX > 250 ? mouseX : mouseX - 250;
            var mouseY = System.Windows.Forms.Control.MousePosition.Y;
            this.Top = SystemParameters.FullPrimaryScreenHeight - mouseY > 200 ? mouseY : mouseY - 200;

            this.KeyDown += (s, e) => { 
                if(e.Key == Key.Escape) {
                    this.Close();
                }
            };

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed || e.OriginalSource is Canvas || Mouse.GetPosition(this).Y > 65)
                return;
            this.DragMove();
        }
    }
}
